// LineProperties.cpp : implementation file
//

#include "stdafx.h"
#include "resourcemake.h"
#include "LineProperties.h"
#include "resourcemakeDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CLineProperties dialog


CLineProperties::CLineProperties(CWnd* pParent /*=NULL*/)
	: CDialog(CLineProperties::IDD, pParent)
{
	//{{AFX_DATA_INIT(CLineProperties)
	m_LineStyle = _T("");
	m_LineWidth = _T("");
	//}}AFX_DATA_INIT
}


void CLineProperties::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CLineProperties)
	DDX_Control(pDX, IDC_BUTTON_COLOR, m_BtnColor);
	DDX_CBString(pDX, IDC_LINESTYLE, m_LineStyle);
	DDX_CBString(pDX, IDC_LINEWIDTH, m_LineWidth);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CLineProperties, CDialog)
	//{{AFX_MSG_MAP(CLineProperties)
	ON_BN_CLICKED(IDC_BUTTON_COLOR, OnButtonColor)
	ON_CBN_SELCHANGE(IDC_LINEWIDTH, OnSelchangeLinewidth)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CLineProperties message handlers

BOOL CLineProperties::OnInitDialog() 
{
	CDialog::OnInitDialog();
	CString str;
	for(int i=0;i<10;i++)
	{
		str.Format("%d",i+1);
		((CComboBox*)GetDlgItem(IDC_LINEWIDTH))->InsertString(i,str);
	}


	// TODO: Add extra initialization here
//	CString str_RGB;
//	str_RGB.Format("%d:%d:%d",GetRValue(m_LineColor),GetGValue(m_LineColor),GetBValue(m_LineColor));
//	this->m_BtnColor.SetWindowText(str_RGB);
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CLineProperties::OnButtonColor() 
{
	// TODO: Add your control notification handler code here
	( (CResourcemakeDlg*) AfxGetApp()->m_pMainWnd) ->m_IsSaveSsml = FALSE;

	CColorDialog dlg(m_LineColor); 
	if (dlg.DoModal()==IDOK)
	{
		m_LineColor=dlg.GetColor();
		CString str_RGB;
		str_RGB.Format("%d:%d:%d",GetRValue(m_LineColor),GetGValue(m_LineColor),GetBValue(m_LineColor));
		this->m_BtnColor.SetWindowText(str_RGB);
		this->Invalidate(TRUE); 
		m_pCurrObj->LineColor = m_LineColor;
		((CResourcemakeDlg *)AfxGetApp()->m_pMainWnd)->m_ddd->Invalidate();
	}	
}

void CLineProperties::OnSelchangeLinewidth() 
{
	// TODO: Add your control notification handler code here
	( (CResourcemakeDlg*) AfxGetApp()->m_pMainWnd) ->m_IsSaveSsml = FALSE;

	int m = ((CComboBox*)GetDlgItem(IDC_LINEWIDTH))->GetCurSel();
	m_LineWidth.Format("%d",m+1);
	m_pCurrObj->LineWidth = m+1;
	((CResourcemakeDlg *)AfxGetApp()->m_pMainWnd)->m_ddd->Invalidate();
}
